// 封装所有文章请求
import request from '@/utils/request.js'

/**
 *获取文章列表
 * @param {Object} params
 * @returns promise
 */
export const getArticalList = params => {
  return request({
    method: 'GET',
    url: '/v1_1/articles',
    params
  })
}

/**
 *获取文章详情
 * @param {Number} id
 * @returns promise
 */
export const getArticalInfo = id => {
  return request({
    method: 'GET',
    url: '/v1_0/articles/' + id
  })
}

/**
 *添加文章收藏
 * @param {*} id 用户id
 * @returns
 */
export const addArticleCollect = id => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target: id
    }
  })
}

/**
 *取消文章收藏
 * @param {*} id 用户id
 * @returns
 */
export const deleteArticleCollect = id => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/collections/' + id
  })
}

/**
 * 对文章点赞
 * @param {*} id 点赞的文章id
 * @returns
 */
export const addArticleGood = id => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target: id
    }
  })
}

/**
 * 取消对文章的点赞
 * @param {*} id 文章id
 * @returns
 */
export const deleteArticleGood = id => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/likings/' + id
  })
}
